<template>
	<view class="page">
		<view class='container'>
		    <view class="separator"></view>
		        <view bindchange="changeRadio" v-if="list.length > 0">
		     
		                <view class="address" :key="address.id" v-for="(address,index) in list">
		                    <view class="address-content">
		                        <view class="address-name">
		                            <text>姓名：{{address.call_name}}</text>
		                            <text>{{address.phone}}</text>
		                        </view>
		                       
		                        <view class="address-detail">
		                            <text>上门地址：{{address.school}}{{address.detail}}</text>
		                        </view>
		                    </view>
		                    <view class="address-operate">
		                        <view class="checkbox">
		                            <!--<radio color="red" value="{{address.id}}" checked="{{address.is_default == 1}}"/>-->
		                            <image class="radio-image" src="../../../static/images/icon/checking.png" :data-id="address.id" v-if="address.is_default == 0" bindtap="changeRadio"></image>
		                            <image class="radio-image" src="../../../static/images/icon/checked.png" :data-id="address.id" v-else bindtap="changeRadio"></image>
		                            <view>设为默认地址</view>
		                        </view>
		                        <view class="edit-address" :data-id="address.id" bindtap="eidtAddress">编辑</view>
		                        <view class="delete-address" :data-id="address.id" bindtap="deleteAddress">删除</view>
		                        <view>
		                        </view>
		                        <view>
		                        </view>
		                    </view>
		                </view>
		        </view>
		    <view class="no-address" v-else>
		        暂无地址！
		    </view>
		    <view class="add-address" @tap="addAddress">
		        新增收货地址
		    </view>
		</view>
	</view>
</template>

<script>
	import tools from '@/static/utils/tools.js'
	var userInfo = ''
	export default {
		data() {
			return {
				list:[],
			}
		},
		
		onShow() {
			this.getAddressList();
		},
		methods: {
			
			//获取地址列表
			getAddressList(){
				let _this = this;
				userInfo = uni.getStorageSync('userInfo');
				var user_id = 4829;//userInfo.id
				tools.httpClient('get','index.php?c=shop&a=addressList',{id: user_id },(res) => {
					console.log(res,123)
					_this.list = res
					
				});
			},
			addAddress(){
				uni.navigateTo({
					url:'../add/add'
				})
			}
		}
	}
</script>

<style>
.page {
    background-color: #f0f0f0;
    -webkit-text-size-adjust: 100%;
    font-family: "微软雅黑";
}
.container {
  padding: 0rpx;
  padding-bottom: 100rpx;
  width: 750rpx;
  background-color: #fff;
  height: 100%;
}
.container .separator{
  padding: 5px;
  width: 100%;
  background-color: #F2F2F2;
}
.container radio-group{
    width: 100%;
}
.container .address {
  /* width: 690rpx; */
  /* width: 100%; */
  /* margin: 20rpx 20rpx 0 20rpx; */
  /* border: 1rpx solid #ccc; */
  /* border-radius: 10rpx; */
  background-color: #fff;
  color: #656565;
  padding: 0 20rpx; 
}

.container .address .address-content {
  border-bottom: 1rpx solid #ccc;
   padding: 10rpx 0; 
  line-height: 1.7;
}

.container .address .address-content .address-name {
  color: black;
  font-size: 1.2em;
  justify-content: space-between;
  display: flex;
  padding: 20rpx 0;
}
.container .address .address-detail{
  padding-bottom: 20rpx;
}
.container .address .address-operate {
   padding: 20rpx 0;
  display: flex;
  /* position: relative; */
  line-height: 1.7;   
  margin-bottom: 10rpx;
}
.container .address .address-operate .checkbox{
  display: flex;
  align-items: center;
}
.container .address .address-operate .radio-image{
  width: 38rpx;
  height: 38rpx;
  padding-right: 8rpx;
}
.container .address .address-operate .edit-address {
  position: absolute;
  right: 140rpx;
  /*color: #e43339;*/
  border: 1rpx #ccc solid;
   padding: 0rpx 10rpx;
}

.container .address .address-operate .delete-address {
  position: absolute;
  right: 20rpx;
  /*color: #e43339;*/
  border: 1rpx #ccc solid;
  padding: 0rpx 10rpx;
}

.no-address{
	display: flex;
	justify-content: center;
	padding-top: 20px;
	background: #fff;
}
.container .add-address {
  color: #010105;
  background-color: #fff;
  width: 100%;
  text-align: center;
  position: fixed;
  bottom: 0;
  /* border-radius: 10rpx; */
  line-height: 80rpx;
  left: 0;
}

</style>
